<?php
declare (strict_types = 1);

namespace app\index\validate;

use think\Validate;

class Comment extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     *
     * @var array
     */	
	protected $rule = [
	    'id'           => 'require|number',
	    'cid'          => 'require|number',
	    'nickname'     => 'require',
        'username'     => 'require',
        'email'        => 'require|email',
        'content'      => 'require',
    ];
    
    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */	
    protected $message = [
        'id.require'           => 'ID参数不能为空',
        'id.number'            => 'ID参数错误',
        'cid.require'          => '内容参数不能为空',
        'cid.number'           => '内容参数错误',
        'nickname.require'     => '昵称不能为空',
        'username.require'     => '用户名不能为空',
        'email.require'        => '请输入邮箱',
        'email'                => '邮箱格式错误',
        'content.require'      => '留言内容不能为空',
    ];

    /**
     * 定义情景信息
     *
     * @var array
     */
    protected $scene = [
        'comment'   => ['cid', 'nickname', 'email', 'content'],
    ];
}
